package com.stagecommon.common.pojo;

import lombok.Data;

import java.io.Serializable;

/**
 * 公共返回对象
 *
 * @author: yxl
 * @create: 2021-11-05 11:27
 **/

@Data

public class RespBean<T> implements Serializable {
    private Integer code;
    private String message;
    private T data;
    private String tokenValue;
    private String disableLogin;
    private long timeStamp = System.currentTimeMillis();

    public static <T> RespBean<T> fail(String info,String disableLogin){
        RespBean<T> respBean = new RespBean<>();
        respBean.setMessage(info);
        respBean.setCode(-1);
        respBean.setDisableLogin(disableLogin);
        return respBean;
    }

    public static RespBean failMessage(String info, String disableLogin){
      return fail(info,disableLogin);
    }

    public static <T> RespBean<T> operationFail(String info){
        RespBean<T> respBean = new RespBean<>();
        respBean.setCode(-10);
        respBean.setMessage(info);
        return respBean;
    }

    public static <T> RespBean<T> operationSuccess(String info,Integer code ,T data){
        RespBean<T> respBean = new RespBean<>();
        respBean.setCode(code);
        respBean.setMessage(info);
        respBean.setData(data);
        return respBean;
    }

    public static <T> RespBean<T> loginSuccessReturnToken(String info,Integer code ,T data,String token){
        RespBean<T> respBean = new RespBean<>();
        respBean.setCode(code);
        respBean.setMessage(info);
        respBean.setData(data);
        respBean.setTokenValue(token);
        return respBean;
    }
}
